package com.qiyu.db;

import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import com.qiyu.entity.Student;

import java.sql.SQLException;

/**
 * @Author： gebilaozhongyi
 * @Company：
 * @CreateTime： 2024-06-28 20:52
 * @Description：
 */
public class StudentDBUtil {
    //DB 数据库操作：https://www.hutool.cn/docs/#/db/%E6%95%B0%E6%8D%AE%E5%BA%93%E7%AE%80%E5%8D%95%E6%93%8D%E4%BD%9C-Db
    public static void insertStudent(Student student) {
        try {
            Db.use().insert(
                    Entity.create("student")
                            .set("num", student.getNum())
                            .set("name", student.getName())
                            .set("sex", student.getSex())
                            .set("math", student.getMath())
                            .set("english", student.getEnglish())
                            .set("china", student.getChina())
            );
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
